package com.share.tool.jni;

import lombok.extern.slf4j.Slf4j;

import java.io.File;

/**
 * 先调用这个jar初始化
 */
@Slf4j
public class AppJni {

    private static String algorithm[] = {"des", "rsa"};

    /**
     * 初始化加载
     */
    public static void init() {
        String sufix = null;
        String osName = System.getProperty("os.name");
        if (osName.toLowerCase().indexOf("windows") > -1) {
            sufix = "lib.a";
            log.info("windows环境-加载lib库");
        } else {
            sufix = "lib.so";
            log.info("linux环境-加载lib库");

        }

        for (String algo : algorithm) {
            String libFilePath = algo + File.separator + algo + sufix;
            log.info("正在加载lib={}", libFilePath);
            System.loadLibrary(libFilePath);
        }
    }
}
